<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">  <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">常规促销异动申请明细</h2>
    </div>
    <!-- 标题 -->
    <div >
    <form id="f1" class="form-inline">
    <input type="hidden" name="aid" value="{$aid}"/>
      <table class="table row-margin-top table-bordered bud_hei">
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >主题</label></td>
             <td colspan="7" class="font-bold">{$apply.title}</td>
          </tr>
          <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >编号</label></td>
             <td>{$apply.no}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >原申请编号</label></td>
             <td>{if condition="$apply.yuanno neq ''"}{$apply.yuanno}{else/}无 {/if}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >修改后编号</label></td>
              <td>{if condition="$apply.nextno neq ''"}{$apply.nextno}{else/}无 {/if}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >状态</label></td>
             <td>{$apply.zhuangtai}</td>
          </tr>
           <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >申请人</label></td>
             <td><a href="javascript:;">{$apply.cname}({$apply.job_name})</a></td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >申请人部门</label></td>
             <td>{$apply.de_name}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >申请时间</label></td>
             <td>{$apply.created_on}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >经销商性质</label></td>
             <td>经销</td>
          </tr>
           <tr>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >经销商名称</label></td>
             <td><span class="font-bold">{$apply.jingxiao} <a href="AgencyYijuDetail.html"><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true"></span></a></span></td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >所属分区</label></td>
             <td>{$apply.fenqu}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >所属省份</label></td>
             <td>{$apply.sheng}</td>
             <td style="min-width: 120px;width: 120px"><label for="" class="form-label" >所属城市</label></td>
             <td>{$apply.shi}</td>
          </tr>
      </table>
       <table class="table row-margin-top table-bordered text-center bud_hei" id="tb">
         <thead>
          <tr class="info">
             <th class="text-center" rowspan="2">状态</th>
             <th class="text-center" rowspan="2">审批人</th>
             <th class="text-center" rowspan="2">核查结果</th>
             <th class="text-center" rowspan="2">序号</th>
            <th class="text-center"  rowspan="2">明细编号</th>
              <th class="text-center" rowspan="2">负责人</th>
              <th class="text-center" rowspan="2">经销商</th>
            <th class="text-center" rowspan="2">系统名称</th>


            <!--<th class="text-center" rowspan="2">经销商</th>
              <th class="text-center" rowspan="2">系统名称</th>-->

              <th class="text-center" rowspan="2">网点名称</th>
            <th class="text-center" rowspan="2">品牌</th>

              <th class="text-center" rowspan="2">品类</th>
              <th class="text-center" rowspan="2">产品系列</th>
              <th class="text-center" rowspan="2">SKU</th>

            <th class="text-center">促销产品</th>
            <th class="text-center" rowspan="2">三级费用科目</th>
             <th class="text-center" colspan="5">异动前费用</th> <!-- 注释掉 两个 需补差销量 colspan 从6变成5 -->
             <th class="text-center" colspan="5">异动后费用</th> <!-- 注释掉 两个 需补差销量 colspan 从6变成5 -->
             <th class="text-center" rowspan="2">已核销金额(元)</th>
             <th class="text-center" rowspan="2">费用描述</th>
             <th class="text-center" rowspan="2">预计费用率</th>
             <th class="text-center" rowspan="2">基准销量</th>
            <th class="text-center" rowspan="2">预计ROI</th>
            <th class="text-center" rowspan="2">费用<br>支付方式</th>
            <th class="text-center" rowspan="2">原促销执行时间</th>
            <th class="text-center" rowspan="2">异动后促销执行时间</th>
            <th class="text-center" rowspan="2">预计核销时间</th>
            <th class="text-center" rowspan="2">异动原因<span class="colorRed">*</span><br>
              <span class="colorRed">(要异动的促销必须填原因，不填原因视为不异动！)</span>
            </th>
          </tr>
           <tr class="info">
            <th class="text-center">单品</th>
            <!--<th class="text-center">需补差销量</th>-->
            <th class="text-center">未税费用金额(元)</th>
            <th class="text-center">是否增值税<br>(可抵扣)</th>
            <th class="text-center">税率</th>
            <th class="text-center">含税费用金额(元)</th>
            <th class="text-center">实际投入费用(元)</th>
            <!--<th class="text-center">需补差销量</th>-->
            <th class="text-center">未税费用金额(元)</th>
            <th class="text-center">是否增值税<br>(可抵扣)</th>
            <th class="text-center">税率</th>
            <th class="text-center">含税费用金额(元)</th>
            <th class="text-center">实际投入费用(元)</th>
         </thead>


          {volist name="applyde" id="vo1" key="j"}

                <tr class="text-left" {if condition="$vo1.tag eq 1"} style="color:green;" {/if}>
                  <input type="hidden" name="did[]" value="{$vo1.did}"/>
                  <td>
                    {switch name="$vo1.tag" }
                         {case value="0"}
                          正常
                        {/case}
                         {case value="1"}
                          异动
                        {/case}
                         {case value="2"}
                          取消
                        {/case}
                    {/switch}
                  </td><td>无</td><td>无</td><td>{$j}</td>


                  <td><a href="formalcxylb.html"> {$vo1.no}-{$vo1.detail_no}</a><a href="detailNum.html"><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
           <td>{$vo1.fuzeren}</td>
           <td>{$vo1.jxs}</td><td>{$vo1.xitong}</td>
                   <td>{$vo1.net}<a href="netjcYj.html"><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
           <td>{$vo1.brand_name}</td>
           <td>{$vo1.category_name}</td>

                    <td>{$vo1.series_name}<a href="ROIjcyj.html"><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
           <td>{$vo1.sku_name}</td>

           <td><span class="glyphicon glyphicon-warning-sign jinchang" aria-hidden="true" title="此条码在申请时未进场"></span>{$vo1.pro_name}<a href="ROIjcyj.html"><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>

           <td>{$vo1.feiyong3}</td><td class="text-right"><span class="num2 weishui">{$vo1.pifuzonge}</span></td><td>{if condition="$vo1.dikou eq 1"}可{else/}否{/if}</td><td class="text-right">{$vo1.shuilv}%</td><td class="text-right"><span class="num2">{$vo1.hanshui}</span></td><td class="text-right"><span class="num2 hs">{$vo1.hanshui}</span></td>

                     <td><input type="text" class="form-control zonge num2i" name="zonge[]" value="{$vo1.pifuzonge}"/></td>

           <td class="text-center">
                      <input type="hidden" name="dikou[]" class='dikou' value="{$vo1.dikou}"/>
                         <div class="form-group">
                            <label class="radio-inline">
                               <input type="radio" class="shi" name="is_di{$j}" value="1" {if condition="$vo1.dikou eq 1"} checked{/if}>是
                            </label>
                             <label class="radio-inline">
                                  <input type="radio" class='fou' {if condition="$vo1.dikou eq 0"} checked{/if} name="is_di{$j}" value="0">否
                            </label>
                        </div>
                     </td>


                      <td><input type="text" name="shuilv[]" class='ysl' value="{$vo1.shuilv}" class="form-control" style="min-width: 80px;width: 80px">%</td>
                      <td class="text-right"><span class="num2 yhs">{$vo1.hanshui}</span></td><td class="text-right"><span class="num2">{$vo1.hanshui}</span></td><td>未核销</td>
                      <td>{$vo1.remark}</td><td>{$vo1.yjfyl}</td><td>{$vo1.totalBenchmarkSales}</td><td>{$vo1.yujiroi}</td>
                      <td>
                           <select name="zfid[]" class="form-control">
                             {volist name="fipay" id="fi"}
                                {if condition="$fi.id eq $vo1.zfid"}
                                <option value="{$fi.id}" selected>{$fi.title}</option>
                                {else/}
                                <option value="{$fi.id}">{$fi.title}</option>
                                {/if}
                             {/volist}
                          </select>
                      </td>
                      <td>{$vo1.start_time}<br/>{$vo1.end_time}</td>
                      <td>从<input type="text" class="form-control layer-date start" name="start_time[]" value={$vo1.start_time} style="min-width: 110px;width: 100px"><br><br>至<input type="text" class="form-control layer-date end"  value={$vo1.end_time} name="end_time[]"  style="min-width: 100px;width: 110px"></td>
                       <td><input type="text"  class="form-control layer-date preverifyTime" name="hexiao_time[]"  value={$vo1.hexiao_time}></td>
                        <td><input type="text" class="form-control yidongyuanyin"  name="yidongyuanyin[]"></td>
                </tr>

          {/volist}
   <!--//-->
        <tr class="text-right font-bold">
          <td colspan="12" >合计</td>
          <td></td>
          <td></td>
          <td></td>
          <!--<td class="ObjectNum" id="zongbcs">0333</td>-->
          <td class="ObjectNum" id="zongws">22656</td>
          <td></td>
          <td></td>
          <td class="ObjectNum zonghs">22656</td>
          <td class="ObjectNum zonghs">22656</td>
          <!--<td>呃呃呃</td>-->
          <td></td>
          <td></td>
          <td></td>
          <td class="ObjectNum zongyhs">22656</td>
          <td class="ObjectNum zongyhs">22656</td>
          <td></td>
          <td></td>
          <td><span class="ObjectNum"></span>%</td>
          <td></td>
          <td><span class="ObjectNum"></span>%</td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
     
      </table>
       <table class="table table-bordered" style="margin:0;padding: 0">
          <tr>
            <td class="font-bold">本申请中包含<span>{$net_num}</span>个网点，其中促销折让与折扣：<span class="ObjectNum zongyhs">22656</span>元；总费用：<span class="ObjectNum zongyhs">22656</span>元。总预计销量：<span class="ObjectNum">{$xiao}</span>元；</td>
          </tr>
      </table>
         <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                  
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>
         <div class="row sub_btn" style="width:100%;text-align:center;padding: 20px 0">
         <input type="hidden" name="state" id="ste"/>
        <input type="button" class="btn btn-success" value="保存为草稿" onclick="baocun(1);">
        <input type="button" class="btn btn-info" value="保存并提交流程" onclick="baocun(3);">
        <input type="button" class="btn btn-warning" value="返回" onclick="back();">
    </div>
</form>
    </div>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
   <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
         <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script>
//保存
function baocun(state){
  $("#ste").val(state);
 
       $(".num2").each(function(){
                if(!isNaN(parseFloat($(this).html())))
                 var num=parseFloat($(this).html()).toFixed(2);
                else
                    var num="0.00";
                $(this).html(num);
            })
              $(".num2i").each(function(){
                if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="0.00";
                $(this).val(num);
            })
              var flag=0;
      $(".yidongyuanyin").each(function(){
          if($(this).val()!=""){
            flag=1;
          }
      })
      if(flag==0){
        swal({
                    title: "错误",
                    text:  "至少一条明细发生异动",
                    type: "warning"
                    });
      }else{
          $.ajax({
                        cache: true,
                        type: "POST",
                        url:"{:url('TiFeiyong/yidongchuli')}",
                        data:$('#f1').serialize(),// 你的formid
                        async: false,
                        error: function(requests) {
                            alert("Connection error");
                        },
                        success: function(datas) {
                         // alert(datas);
                          
                          var res1=JSON.parse(datas);
                          if(res1["state"]==1){
                            swal({
                            title: "完成",
                            text: "操作已成功",
                            type: "success"
                            },function(){
                              
                              location.href="{:url('TiFeiyong/index')}";
                            });

                                  }else{
                                    swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                                  }
                          }
                    });
      }
  
}
//异动后含税总额
function hesuanyhs(){
   var num=0;
 $(".yhs").each(function(){
    if($(this).html()!=""){
      num+=parseFloat($(this).html());
    }
    // alert(num);
  })
 $(".zongyhs").html(num.toFixed(2));

}

//核算补差总数

function hesuanbucha(){
  var num=0;
  $(".bcs").each(function(){
    if($(this).html()!=""){
      num+=parseFloat($(this).html());
    }
    // alert(num);
  })
 
  $("#zongbcs").html(num.toFixed(2));

}
//核算总额
function hesuanweishui(){
  var num=0;
 $(".weishui").each(function(){
    if($(this).html()!=""){
      num+=parseFloat($(this).html());
    }
    // alert(num);
  })
 $("#zongws").html(num.toFixed(2));

}
//核算含税
function hesuanhs(){
   var num=0;
 $(".hs").each(function(){
    if($(this).html()!=""){
      num+=parseFloat($(this).html());
    }
    // alert(num);
  })
 $(".zonghs").html(num.toFixed(2));

}
 $(".zonge").blur(function(){
  var money=0;
    if(!isNaN(parseFloat($(this).val()))){

      money=parseFloat($(this).val());
      
    }
    $(this).val(money);
    var shui=parseFloat($(this).parent().next().next().children().val());
    var jieguo=(money+money*shui/100).toFixed(2);
    $(this).parent().next().next().next().html("<span class='num2 yhs'>"+jieguo+"</span>").next().html("<span class='num2'>"+jieguo+"</span>");
     hesuanyhs();
 })

$(".ysl").blur(function(){
  var shui=0;
   if(!isNaN(parseFloat($(this).val()))){

     shui=parseFloat($(this).val());
      
    }
    $(this).val(shui);
    var money=parseFloat($(this).parent().prev().prev().children().val());
    var jieguo=(money+money*shui/100).toFixed(2);
     $(this).parent().next().html("<span class='num2 yhs'>"+jieguo+"</span>").next().html("<span class='num2'>"+jieguo+"</span>");
     hesuanyhs();
})

</script>
     <!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
    <script>
           $(document).ready(function(){
             $(".num2").each(function(){
                if(!isNaN(parseFloat($(this).html())))
                 var num=parseFloat($(this).html()).toFixed(2);
                else
                    var num="0.00";
                $(this).html(num);
            })
              $(".num2i").each(function(){
                if(!isNaN(parseFloat($(this).val())))
                 var num=parseFloat($(this).val()).toFixed(2);
                else
                    var num="0.00";
                $(this).val(num);
            })
  hesuanbucha();
  hesuanweishui();
  hesuanhs();
  hesuanyhs();
              $(".shi").change(function(){

                if($(this).prop("checked")){
                 
                  $(this).parent().parent().prev().val(1);
                }
              })
            $(".fou").change(function(){

                if($(this).prop("checked")){
                 
                  $(this).parent().parent().prev().val(0);
                }
              })
             laydate({
            elem: '#tb .preverifyTime', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
        });
          var start = {
            elem: '#tb .start',
            format: 'YYYY-MM-DD',
           
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false
        };
        var end = {
            elem: '#tb .end',
            format: 'YYYY-MM-DD',
           
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            
        };
        laydate(start);
        laydate(end);
        function back(){
          location.href="{:url('TiFeiyong/index')}";
        }

      })

       // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

       
    });
   function back(){
    location.href="{:url('TiFeiyong/index')}";
   }
    </script>
</body>

</html>
